import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        sc.nextLine();
        String[] s = sc.nextLine().trim().split(" ");
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(s[i]);
        }
        int[] xnums = new int[m];
        for (int i = 0; i < m; i++) {
            xnums[i] = sc.nextInt();
        }
        function(n, m, nums, xnums);
    }
    public static void function(int n, int m, int[] arr, int[] xarr) {
        for (int k = 0; k < m; k++) {
            int start = 0, tail = 0;
            for (int i = 0; i < n; i++) {
                if (arr[i] == xarr[k]) {
                    start = i + 1;
                    break;
                }
            }
            if (start == 0) {
                System.out.println(0);
                continue;
            }
            for (int j = n - 1; j >= 0; j--) {
                if (arr[j] == xarr[k]) {
                    tail = j + 1;
                    break;
                }
            }
            System.out.println(start + " " + tail);
        }
    }
}
